#include <logger.h>
using namespace std;

Logger::Logger()
{
}

Logger::~Logger()
{
    delete format_;
    format_ = nullptr;
    delete out_;
    out_ = nullptr;
}

void Logger::Write(XLog level, const std::string &log, const std::string &file, int line)
{

    if (level < log_level_) return;
    string levelstr = "debuge";

    switch (level)
    {
    case XLog::DEBUG:
        levelstr = "debuge";
        break;
    case XLog::INFO:
        levelstr = "info";
        break;
    case XLog::ERROR:
        levelstr = "error";
        break;
    case XLog::FATAL:
        levelstr = "fatal";
        break;

    default:
        break;
    }

    auto logstr = format_->Format(levelstr, log, file, line);
    out_->Output(logstr);
}
